package com.example.demo.controller;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.PropertySource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import com.example.demo.props.PropertiesConfig;

import springfox.documentation.swagger2.annotations.EnableSwagger2;


/**
 * 获取properties文件信息第一种方式
 * @ConfigurationProperties(prefix="person")
 *@PropertySource(value="classpath:conf.yml")
 * @author jiaqi.liu
 *
 */
@RestController
@EnableSwagger2
public class PropsControllerDemo1 {
	
	
	@Resource(name="propertiesConfig")
	private PropertiesConfig propertiesConfig;
	
	@GetMapping("/getPropsMethodOne")
	public Map<String,String> getProps(){
		Map<String,String> map=new HashMap<String,String>();
		map.put("name", propertiesConfig.getName());
		map.put("age", propertiesConfig.getAge());
		return map;
	}
	

}
